package com.example.demo2.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.demo2.util.BackToOrigin;
import com.example.demo2.util.TransferPage;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

import java.nio.channels.Selector;

/**
 * @description This class is for user interaction between users and flight information display page
 * @version 2.0
 */

public class InfoController {
    @FXML
    private Button backButton;

    @FXML
    private TextArea text1;

    @FXML
    private TextArea text2;

    @FXML
    private RadioButton Selector1;

    @FXML
    private RadioButton Selector2;

    @FXML
    private Button confirmButton;

//    @FXML
//    public void setText1(JSONObject object){
//        TransferPage.transfer("flight-info", "Flight Info", 600, 1000);
//        String departure = object.getString("departure");
//        String Date = object.getString("Date");
//        String boardingTime = object.getString("boardingTime");
//        String duration = object.getString("duration");
//        String theClass = object.getString("theClass");
//        String destination = object.getString("destination");
//        String text = departure + "-------" + destination + "\n" +
//                Date + "\n" +
//                boardingTime + "\n" +
//                duration + "\n" +
//                "VIP Class" + theClass;
//        text1.setText(text);
//    }
//
//    @FXML
//    public void setText2(JSONObject object){
//        String departure = object.getString("departure");
//        String Date = object.getString("Date");
//        String boardingTime = object.getString("boardingTime");
//        String duration = object.getString("duration");
//        String theClass = object.getString("theClass");
//        String destination = object.getString("destination");
//        String text = departure + "-------" + destination + "\n" +
//                Date + "\n" +
//                boardingTime + "\n" +
//                duration + "\n" +
//                "VIP Class" + theClass;
//        text2.appendText(text);
//    }

    public void backController(ActionEvent event) {
        Stage primaryStage = (Stage) backButton.getScene().getWindow();
        primaryStage.hide();
        TransferPage.transfer("passenger", "Passenger Login",600,1000);
    }

    public void confirmController(ActionEvent event) {

        Stage primaryStage = (Stage) confirmButton.getScene().getWindow();
        primaryStage.hide();

//        BackToOrigin.back();
        TransferPage.transfer("seat-view", "Seat Selector",600,1000);
    }
}
